package cn.stylefeng.guns.modular.erclassify.controller;

import cn.stylefeng.guns.core.annotion.BusinessLog;
import cn.stylefeng.guns.core.enums.LogAnnotionOpTypeEnum;
import cn.stylefeng.guns.core.pojo.response.ResponseData;
import cn.stylefeng.guns.core.pojo.response.SuccessResponseData;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import cn.stylefeng.guns.modular.erclassify.service.ErClassifyService;
import cn.stylefeng.guns.modular.erclassify.model.param.ErClassifyParam;

import javax.annotation.Resource;

/**
 * 分类 控制器
 *
 * @author: w
 * @date: 2021/06/10 09:05
 */
@RestController
public class ErClassifyController {

    @Resource
    private ErClassifyService erClassifyService;

    /**
     * 分页查询分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @GetMapping("/erClassify/page")
    @BusinessLog(title = "分类_分页查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData page(ErClassifyParam erClassifyParam) {
        return new SuccessResponseData(erClassifyService.page(erClassifyParam));
    }

    /**
     * 获取全部分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @GetMapping("/erClassify/list")
    @BusinessLog(title = "分类_查询所有", opType = LogAnnotionOpTypeEnum.QUERY)
    public ResponseData list(ErClassifyParam erClassifyParam) {
        return new SuccessResponseData(erClassifyService.list(erClassifyParam));
    }

    /**
     * 查看详情分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @GetMapping("/erClassify/detail")
    @BusinessLog(title = "分类_查看详情", opType = LogAnnotionOpTypeEnum.DETAIL)
    public ResponseData detail(@Validated(ErClassifyParam.detail.class) ErClassifyParam erClassifyParam) {
        return new SuccessResponseData(erClassifyService.detail(erClassifyParam));
    }

    /**
     * 添加分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @PostMapping("/erClassify/add")
    @BusinessLog(title = "分类_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public ResponseData add(@RequestBody @Validated(ErClassifyParam.add.class) ErClassifyParam erClassifyParam) {
        erClassifyService.add(erClassifyParam);
        return new SuccessResponseData();
    }

    /**
     * 删除分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @PostMapping("/erClassify/delete")
    @BusinessLog(title = "分类_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public ResponseData delete(@RequestBody @Validated(ErClassifyParam.delete.class) ErClassifyParam erClassifyParam) {
        erClassifyService.delete(erClassifyParam);
        return new SuccessResponseData();
    }

    /**
     * 编辑分类
     *
     * @author w
     * @date 2021/06/10 09:05
     */
    @PostMapping("/erClassify/edit")
    @BusinessLog(title = "分类_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public ResponseData edit(@RequestBody @Validated(ErClassifyParam.edit.class) ErClassifyParam erClassifyParam) {
        erClassifyService.edit(erClassifyParam);
        return new SuccessResponseData();
    }


}
